﻿package com.winmastergames.gameassets 
{
	import flash.net.SharedObject;
	
	/**
	 * ...
	 * @author Taylor
	 */
	public class achievement 
	{
		public var name:String;
		public var required:Number;
		public var frequency:int;
		public var poppedUp:Boolean = false;
		public var gotten:Boolean = false;
		var sharedObject:SharedObject;
		var sharedName:String;
		public var total:Number;
		public function achievement(nameF:String, sharedNameF:String, requiredF:Number, frequencyF:int) 
		{
			if (nameF != "null")
			{
				sharedName = sharedNameF;
				name = nameF;
				required = requiredF;
				frequency = frequencyF;
				sharedObject = SharedObject.getLocal(sharedName);
				if (sharedObject.data.sharedName == null)
					sharedObject.data.sharedName = 0;
					
				total = sharedObject.data.sharedName;
				trace(total);
			}
		}
		
		public function save()
		{
			sharedObject.data.sharedName = total;
			sharedObject.flush();
			sharedObject.close();
		}
	}
}